package se.statemachine.fsm.interfacestyle;

import junit.framework.TestCase;

public class TestStateCycle extends TestCase{
	
	/**
	 * Locked Coin Unlocked Unlock 	
	 */		
	public void testLockCoin(){
		
		TurnstileFSM fsm = new TurnstileFSM();
				
		TurnstileFSM.setState(TurnstileFSM.locked);
		assertTrue(TurnstileFSM.getState().toString().equals("LockedState"));
		
		fsm.coin();
		assertTrue(TurnstileFSM.getState().toString().equals("UnlockedState"));
	}
	
	/**
	 *  Locked Pass Locked Alarm
	 */
	public void testLockPass(){
		
		TurnstileFSM fsm = new TurnstileFSM();
				
		TurnstileFSM.setState(TurnstileFSM.locked);
		assertTrue(TurnstileFSM.getState().toString().equals("LockedState"));
		
		fsm.pass();
		assertTrue(TurnstileFSM.getState().toString().equals("LockedState"));
	}
	
	/**
	 * Unlocked Coin Unlocked Thankyou
	 */
	public void testUnlockCoin(){
		
		TurnstileFSM fsm = new TurnstileFSM();
				
		TurnstileFSM.setState(TurnstileFSM.unlocked);
		assertTrue(TurnstileFSM.getState().toString().equals("UnlockedState"));
		
		fsm.coin();
		assertTrue(TurnstileFSM.getState().toString().equals("UnlockedState"));
	}
	
	/**
	 * Unlocked Pass Locked Lock
	 */
	public void testUnlockPass(){
		
		TurnstileFSM fsm = new TurnstileFSM();
		
		TurnstileFSM.setState(TurnstileFSM.unlocked);
		assertTrue(TurnstileFSM.getState().toString().equals("UnlockedState"));
		
		fsm.pass();
		assertTrue(TurnstileFSM.getState().toString().equals("LockedState"));
	}
}
